/********************************************************************************
 *      Copyright:  (C) 2021 iot
 *                  All rights reserved.
 *
 *       Filename:  hal.h
 *    Description:  This head file 
 *
 *        Version:  1.0.0
 *         Author:  mk
 *                 
 ********************************************************************************/
#ifndef _HAL_H_
#define _HAL_H_

#include <gpiod.h>

#define OFF 0
#define ON  1

/* Three light*/
enum
{
    GREEN = 0,
    RED,
    BLUE,
    LIGHT_MAX,
};

typedef struct light_ctx_s
{
    int           light_cnt;
    int           light_pins[LIGHT_MAX];  

    float         lux_threshold;   

    int           infrared_pin;    

    int           light_intval; 

}light_ctx_t;


/*  init hardware */
extern int hal_init(light_ctx_t *ctx);

/*turn which light on/off*/
extern void turn_light(int gpio_line, int on_off);

/*  terminal hardware */
extern void hal_term(light_ctx_t *ctx);

/*  Return value: 1(HIGH): Sombody detected  0(LOW): Nobody detected */
extern int infrared_detect(void);

#endif


